package cn.innosmart.aq.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.HashMap;

import cn.innosmart.aq.R;

/**
 * @Deprecated
 * Created by David on 2015/8/7.
 */
public class PriorityInfoAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater mInflater;
    private HashMap<String, String> results;
    private ArrayList<String> list;
    private int choosenPosition;

    public PriorityInfoAdapter(Context context, ArrayList<String> list, HashMap<String, String> results) {
        this.context = context;
        mInflater = LayoutInflater.from(context);
        this.results = results;
        this.list =list;
        this.choosenPosition = 0;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.listview_help_info_list, null);
            holder.tvName = (TextView) convertView.findViewById(R.id.tv_name);
            holder.tvCondition = (TextView) convertView.findViewById(R.id.tv_condition);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        String name = list.get(position);
        holder.tvName.setText(name);
        String condition = results.get(name);
        holder.tvCondition.setText(condition);
        return convertView;
    }

    private View.OnClickListener onClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            int position = (int) v.getTag();
            choosenPosition = position;
            notifyDataSetChanged();
        }
    };

    public int getChoosenPosition() {
        return choosenPosition;
    }

    public void setChoosenPosition(int choosenPosition) {
        this.choosenPosition = choosenPosition;
    }

    static class ViewHolder {
        TextView tvName;
        TextView tvCondition;
    }
}
